const router = require("koa-router")(); //引入路由函数
const swaggerJSDoc = require("swagger-jsdoc");
const path = require('path')

const swaggerDefinition = {
  definition: {
    openapi: "3.0.0",
    info: {
      title: "Hello World",
      version: "1.0.0",
    },
  },
};

const options = {
  swaggerDefinition,
  apis: [path.join(__dirname, "../router/*.js")],
};

const swaggerSpec = swaggerJSDoc(options);

// 通过路由获取生成的注解文件
router.get("/swagger.json", async function (ctx) {
  ctx.set("Content-Type", "application/json");
  ctx.body = swaggerSpec;
});

module.exports = router;
//将页面暴露出去
